﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ecreate.Popedom.Dao.Hibernate
{
    public class AreaDaoImpl:IAreaDao
    {

        public IList<tArea> getProvince()
        {
            NHibernate.ISession s = Utility.getSession();
            return s.CreateQuery(" from tArea t where 1=1 and t.AreaLevel=1 ").List<tArea>();
        }
        public IList<tArea> getCity(string AreaCode)
        {
            NHibernate.ISession s = Utility.getSession();
            string hsql = " from tArea t where 1=1  and t.AreaLevel=2 and t.ParentAreacode='"+AreaCode+"'";
            return s.CreateQuery(hsql).List<tArea>();
        }

        public IList<tArea> getCity()
        {
            NHibernate.ISession s = Utility.getSession();
            string hsql = " from tArea t where 1=1  and t.AreaLevel=2 ";
            return s.CreateQuery(hsql).List<tArea>();
        }


        public IList<tArea> getCountry(string AreaCode)
        {
            NHibernate.ISession s = Utility.getSession();
            string hsql = " from tArea t where 1=1  and t.AreaLevel=3 and t.ParentAreacode='" + AreaCode + "'";
            return s.CreateQuery(hsql).List<tArea>();
        }

        public tArea getById(string Id)
        {
            NHibernate.ISession s = Utility.getSession();
            return s.Get<tArea>(Id);
        }


    }
}
